package jzqb.dao.impl;

import cnki.tpi.kbatis.sqlsession.SqlSession;
import cnki.tpi.kbatis.utils.DataSourceUtil;
import jzqb.bo.*;
import jzqb.dao.KnowledgeDao;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 情报知识数据层实现类
 */
@Repository
public class KnowledgeDaoImpl implements KnowledgeDao {

    @Override
    public List<StandKnowleageBo> ComplexSearchGroup(KnowleageConditionBo knowleageConditionBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.KnowledgeDao.ComplexSearchGroup";
        return sqlSession.selectList(statementId, knowleageConditionBo, false);
    }

    @Override
    public Integer getDataSourCount(DataCountBo dataCountBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.KnowledgeDao.getDataSourCount";
        return sqlSession.selectOne(statementId, dataCountBo, false);
    }

    @Override
    public List<StandardBo> ComplexSearch(KnowleageConditionBo knowleageConditionBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.KnowledgeDao.ComplexSearch";
        return sqlSession.selectList(statementId, knowleageConditionBo, false);
    }

    @Override
    public Long findComplexSearchCount(KnowleageConditionBo knowleageConditionBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.KnowledgeDao.findComplexSearchCount";
        return sqlSession.getCount(statementId, knowleageConditionBo);
    }

    @Override
    public QBZSBo getKnowledgeDetail(QBZSBo qbzsBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.KnowledgeDao.getKnowledgeDetail";
        return sqlSession.selectOne(statementId, qbzsBo, false);
    }

    @Override
    public Long selectCountNumber(CountNumberBo countNumberBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.KnowledgeDao.selectCountNumber";
        return sqlSession.getCount(statementId, countNumberBo);
    }

    @Override
    public StandardBo getLocalKnowLeage(QBZSBo qbzsBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.KnowledgeDao.getLocalKnowLeage";
        return sqlSession.selectOne(statementId, qbzsBo, false);
    }

    @Override
    public List<StandardBo> ralatedArticlesList(String sql) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.KnowledgeDao.ralatedArticlesList";
        return sqlSession.selectList(statementId, sql, false);
    }

    @Override
    public StandardBo getBoById(QBZSBo qbzsBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.KnowledgeDao.getBoById";
        return sqlSession.selectOne(statementId, qbzsBo, false);
    }

    @Override
    public Boolean updateDownTime(StandardBo standardBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.KnowledgeDao.updateDownTime";
        return sqlSession.executeUpdate(statementId, standardBo);
    }

    @Override
    public Long findTheValue(KnowleageConditionBo KnowleageConditionBos) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.KnowledgeDao.findTheValue";
        return sqlSession.getCount(statementId, KnowleageConditionBos);
    }

    @Override
    public List<StandardBo> getResultByAuthor(StandardBo standardBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.KnowledgeDao.getResultByAuthor";
        return sqlSession.selectList(statementId, standardBo, false);
    }

    @Override
    public List<StandardBo> getResultByOrganization(StandardBo standardBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.KnowledgeDao.getResultByOrganization";
        return sqlSession.selectList(statementId, standardBo, false);
    }

    @Override
    public List<StandardBo> getResultByKeyword(StandardBo standardBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.KnowledgeDao.getResultByKeyword";
        return sqlSession.selectList(statementId, standardBo, false);
    }

    @Override
    public List<StandardBo> getRalatedArticlesList(StandardBo standardBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.KnowledgeDao.getRalatedArticlesList";
        return sqlSession.selectList(statementId, standardBo, false);
    }
}
